<?php include("includes/startPage.php"); checkLogin(1); ?>
<?php include("process_profile_change.php");?>
<?php include('includes/header.php'); printHeader("My Profile", "Nordic Sauna");?> <!-- (PageTitle, Banner Text) Prints <head>, opens <body> and prints banner -->
<?php include('includes/navigation.php'); printLeftMenu("my_profile"); ?> <!-- Navigation include, (currentpagename) -->

<?php OpenContentSection(); ?> 

<!-- Content Starts -->
<?php 
    if (!isset($userData)) //If user object not made in POST section
    { 
        $userData = ns_dao_user::UserByUsername($_SESSION['username']);
    }
?>

    <div id="ProfileTitle">
        <img src="<?php echo "../../content/avatar/" . $userData->AvatarImage();  ?>" />
        <h1><?php echo $userData->Username(); ?></h1>
    </div>
    <br />
    
    <form name="updateProfile" id="updateProfile" action="my_profile.php" method="POST" onsubmit="return check_profile_form()">
    <input type="hidden" name="username" id="username" value="<?php echo $_SESSION['username']; ?>"/>
    <table>
        <tr>
            <td nowrap="nowrap" valign="top" width="10%">
                <font size="-1">First name:</font>
            </td>
            <td>
                <input name="FirstName" id="FirstName" size="30" value="<?php echo $userData->FirstName(); ?>" type="text">
            </td>
        </tr>
        <tr>
            <td nowrap="nowrap" valign="top" width="10%">
                <font size="-1">Last name:</font>
            </td>
            <td>
                <input name="LastName" id="LastName" size="30" value="<?php echo $userData->LastName(); ?>" type="text">
            </td>
        </tr>
        <tr>
            <td nowrap="nowrap" valign="top" width="10%">
                <font size="-1">Email Address:</font>
            </td>
            <td>
                <input name="Email" id="Email" size="30" value="<?php echo $userData->Email(); ?>" type="text">
            </td>
        </tr>
        <tr>
            <td nowrap="nowrap" valign="top" width="10%">
                <font size="-1">Phone Number:</font>
            </td>
            <td>
                <input name="Phone" id="Phone" size="30" value="<?php echo $userData->Phone(); ?>" type="text">
            </td>
        </tr>
    </table>
    
    <table>
        <tr>
            <td colspan="1">&nbsp;</td>
            <td style="" align="left" nowrap="nowrap">
            <input name="save" id="save" value="Save" style="font-weight: bold;" type="submit">
            <input name="cancel" id="cancel" value="Cancel" type="button" onclick="window.location.href ='index.php'">
            </td>
        </tr>
    </table>
    </form>
    <br />
    
    <form name="uploadAvatar" action="my_profile.php" method="POST" enctype="multipart/form-data">
        <input type="hidden" name="username" id="username" value="<?php echo $_SESSION['username']; ?>"/>
    <h4 style="margin:0">Avatar</h4>
    <table width="100%" border="0" cellspacing="1" cellpadding="1">
        <tr>
            <td nowrap="nowrap" valign="top" width="10%">
                <font size="-1"><label for="avatarFile">Avatar Image:</label></font>
            </td>
            <td>
                <input type="file" name="avatarFile" id="avatarFile" />
            </td>
        </tr>
    </table>
    
    <table>
        <tr>
            <td colspan="1">&nbsp;</td>
            <td style="" align="left" nowrap="nowrap">
                <input type="submit" name="uploadAvatar" style="font-weight: bold;" id="uploadAvatar" value="Update Avatar"/>
            </td>
        </tr>
    </table>
    </form>    

<?php 
    if (isset($messageString))
    {
        echo "<font size=+4, color=Green>&nbsp;&nbsp;" . $messageString . "</font>";
    }
?>
	
	<!-- Content Ends -->
<?php CloseContentSection(); ?> 

<?php include('includes/footer.php');?>
